#include<bits/stdc++.h>
using namespace std;

int w[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
int m[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};

string s[101];

int main()
{
	int n;
	cin>>n;
	int cnt = 0;
	for(int i = 1;i <= n;i++)
	{
		cin>>s[i];
		int flag = 0;
		int sum = 0;
		for(int j = 0;j <= 16;j++)
		{
			if(!('0' <= s[i][j] && s[i][j] <= '9'))
			{
				flag = 1;
				break;
			}
			sum += (int)(s[i][j]-'0')*w[j];
		}
		if(flag || s[i][17] != m[sum%11])
			cout<<s[i]<<endl;
		else
			cnt++;
	}
	if(cnt == n)
		cout<<"All passed";
	return 0;
}

